// 立即执行函数 快速创建闭包

let Singleton=(function(){
    let instance
    return function(name){
        // 返回一个唯一的实例
        if(instance){
            return instance;
        }
        else{
            this.name=name;
            return instance=this;
        }
    }
})()
Singleton.prototype.getname=function(){
    console.log(this.name);
}
let winner = new Singleton('dinnen');
let looset = new Singleton('sjgsg');
console.log(winner==looset);